<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加</title>
</head>
<script src="/js/global.js"></script>
<link rel="stylesheet" href="/css/font.css" type="text/css"/>
<link rel="stylesheet" href="/css/layui.css" type="text/css"/>
<link rel="stylesheet" href="/css/xadmin.css" type="text/css"/>
<script type="text/javascript" src="/js/layui.js" ></script>
<script type="text/javascript" src="/js/xadmin.js" ></script>
<link rel="stylesheet" href="/css/style.css" type="text/css"/>
<script type="text/javascript" src="/js/index.js"></script>
<script type="text/javascript" src="/js/jquery-3.5.1.min.js"></script>
<body>

<div class="layui-form" style="margin-top: 15px;">

    <div class="layui-form-item" style="width: 80%;">
        <label class="layui-form-label">账号</label>
        <div class="layui-input-block">
            <input type="text" name="account" lay-verify="required" placeholder="账号"
                   autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item" style="width: 80%;">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="text" name="password" lay-verify="required" placeholder="密码" autocomplete="off"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item" style="width: 80%;">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" name="username" placeholder="用户名" autocomplete="off" lay-verify="required"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item" style="width: 80%;">
        <label class="layui-form-label">介绍</label>
        <div class="layui-input-block">
            <textarea name="synopsis" class="layui-textarea" id="synopsis" cols="100" rows="5"></textarea>

        </div>
    </div>

    <div class="layui-form-item" style="width: 80%; text-align: center;">
        <button class="layui-btn" lay-submit lay-filter="formDemo">添加</button>
    </div>

</div>
<script type="text/javascript">
    layui.use(['laydate', 'form'], function() {
        var laydate = layui.laydate,
            form = layui.form,
            $ = layui.jquery;

        form.on('submit(formDemo)', function(data) {
            $.post("../supplier/add", data.field, function(res) {
                if (res.code === 200) {
                    layer.msg(res.msg, {
                        icon: 1,
                        time: 2000
                    }, function() {
                        var index = parent.layer.getFrameIndex(window
                            .name); //获取当前窗口的name
                        parent.layer.close(index); //关闭窗口
                    });
                } else {
                    layer.msg(res.msg, {
                        icon: 5,
                        time: 2000
                    });
                }
            })
        });
    })
</script>
</body>
</html>
